package org.itboys.core.controller.web;

import org.itboys.core.entity.mongo.SundayStore;
import org.itboys.core.entity.mysql.SundayStoreNum;
import org.itboys.core.service.mysql.web.SundayStoreNumService;
import org.itboys.core.util.ResponseMessage;
import org.itboys.framework.query.JsonPageUtils;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.param.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author：贾琦磊
 * @Date：2018/8/22
 * @Description：库存管理
 */
@Controller
@RequestMapping("/sunday/web/store/num")
public class SundayStoreNumController extends BaseController{
    @Autowired
    private SundayStoreNumService storeNumService;

    @RequestMapping("/index")
    public String index(HttpServletRequest request, HttpServletResponse response,
                        @RequestParam("storeId") Long storeId
    , Model model){
        model.addAttribute("storeId",storeId);
        return "/sunday/store/num/index";
    }
    @RequestMapping("/select")
    public void select(HttpServletRequest request,HttpServletResponse response
    ,@RequestParam("storeId")Long storeId)throws Exception{
        PageResult<SundayStoreNum> result = storeNumService.findByStoreId(request);
        JsonPageUtils.renderJsonPage(result.getTotal(),result.getData(),response);
    }

}
